\begin{tikzpicture}

	\begin{timelinediagram}

		\renewcommand{\timestepvector}{0,-0.4}

		% initial timelines

		\node[minimum width=22ex, font=\normalsize]
			(producerlabel) {Signal producer};
		\node[minimum width=32ex, font=\normalsize, right of=producerlabel,
		     node distance=31ex]
			(handlerlabel)  {Signal handler};

		\path (producerlabel)+(8ex,-3ex) node (timelineanchor) {};
		\newtimeline{producer}

		\path (handlerlabel)+(-12ex,-3ex) node (timelineanchor) {};
		\newtimeline{handler}

		\node[minimum width=10ex, font=\normalsize, right of=handlerlabel,
		      node distance=28ex] (corelabel) {Core};
		\path (corelabel)+(0ex,-3ex) node (timelineanchor) {};
		\path (corelabel.south) node[below, font=\normalsize] (corepdlabel) {PD};
		\newtimeline{coresignal}

		\activate{producer}
		\activate{handler}
		\timestep

		% entrypoint

		\path (handler)+(2.5,0) node (timelineanchor) {};
		\newtimeline{ep}
		\node[draw, fill=white, align=center, dropshadow] at (ep) {Entrypoint};
		\renewcommand{\timestepvector}{0,-1}
		\timestep

		% create signal context

		\path (handler)+(4,0) node[draw, fill=white, align=center, dropshadow]
			(context) {Signal\\ context \textbf{c}};
		\draw[timelinemessage, dashed] (handler) -- node[above] {$create$} (context);
		\renewcommand{\timestepvector}{0,-0.7}
		\timestep

		% manage context

		\transition{handler}{ep}{manage \textbf{c}}
		\renewcommand{\timestepvector}{0,-0.3}
		\timestep
		\transition{ep}{coresignal}{allocate capability}
		\timestep
		\transition{coresignal}{ep}{}
		\timestep
		\transition{ep}{handler}{}
		\path (transitionlabel)+(1ex,0)
			node[align=center, below] {signal-context \\ capability \textbf{$cap_c$}};
		\renewcommand{\timestepvector}{0,-0.3}
		\timestep

		% delegate context capability

		\draw[timelinemessage, dashed] (handler) -- node[align=center]
			{$delegate$ \\ {\textbf{$cap_c$}}} (producer);
		\timestep

		% create signal transmitter

		\path (producer)+(-13ex,0) node (timelineanchor) {};
		\newtimeline{transmitter}
		\node[draw, fill=white, align=center, dropshadow] at (transmitter)
			(signaltransmitter) {Signal\\ transmitter\\ for \textbf{$cap_c$}};
		\draw[timelinemessage, dashed] (producer) -- node[above] {$create$} (signaltransmitter);
		\timestep

		\deactivate{producer}
		\deactivate{handler}
		\renewcommand{\timestepvector}{0,-1}
		\timestep

		% second part

		\activate{producer}
		\activate{handler}
		\renewcommand{\timestepvector}{0,-0.4}
		\timestep

		% producer submits two signals

		\renewcommand{\timestepvector}{0,-0.2}
		\transition{producer}{transmitter}{submit} \timestep
		\renewcommand{\timestepvector}{0,-0.4}
		\transition{transmitter}{producer}{} \timestep

		\renewcommand{\timestepvector}{0,-0.2}
		\transition{producer}{transmitter}{submit} \timestep
		\renewcommand{\timestepvector}{0,-0.4}
		\transition{transmitter}{producer}{} \timestep

		% handler receives 2 signals

		\renewcommand{\timestepvector}{0,-0.2}
		\transition{handler}{ep}{block} \timestep
		\renewcommand{\timestepvector}{0,-0.6}
		\transition{ep}{handler}{} \timestep
		\path (transitionlabel)+(1ex,0)
			node[align=center, below] {context {\textbf{c}} count {\textbf{2}}};
		\timestep

		% handler waits for signal

		\renewcommand{\timestepvector}{0,-0.8}
		\transition{handler}{ep}{block} \timestep

		% producer submits one signal and immediately wakes up handler

		\transition{producer}{transmitter}{submit}
		\renewcommand{\timestepvector}{0,-0.1}
		\timestep
		\transition{ep}{handler}{}
		\path (transitionlabel)+(1ex,0)
			node[align=center, below] {context {\textbf{c}} count {\textbf{1}}};
		\draw[timelinemessage, dotted, pos=0.75] (transmitter) -- node[above] {$wake$ $up$} (handler);
		\timestep
		\renewcommand{\timestepvector}{0,-0.4}
		\transition{transmitter}{producer}{} \timestep
		\timestep

	\end{timelinediagram}

	\begin{scope}[on background layer]
	\node[timelinegroup, fit=(producerlabel) (transmitter) (producer)] {};
	\node[timelinegroup, fit=(handlerlabel) (context)  (handler)] {};
	\node[timelinegroup, fit=(corelabel) (corepdlabel) (coresignal)] {};
	\end{scope}

\end{tikzpicture}
